const Mock = require('mockjs')
const fs = require('fs')
const data = Mock.mock({
	"goodList|10": [
		{
			"title": "@ctitle(2)",
			"children|10": [{
				"title": "@ctitle",
				"image": "https://robohash.org/@id?set=set@integer(1,5)",
				"price|100-1000.2-4": 1,
				"count|10-20": 1,
				"desc": "@cword(20, 50)",
				"state": false,
				"type|1": ["衣服", "鞋子", "化妆品", "数码", "生活", "食品", "饰品", "药品", "体育", "儿童", "汽车"]
			}]
		}
	]
})

function switchUniAppJSON(data, target) {
	const goodList = JSON.stringify(data)
		.replace('[', '')
		.replace(/\]$/g, '')
		.replace(/\}\]\},\{/g, '}]}{');
	fs.writeFileSync(target, goodList);
	console.log(goodList)
	return goodList
}


switchUniAppJSON(data.goodList, './goodList.json')